{template admin/head}
<script type="text/javascript" src="{STATICDIR}third/plupload/plupload.full.min.js"></script>
<script type="text/javascript">

function submitcheck(){
	return true;
}

function saveInfo()
{
	if(!submitcheck())
	{
		return;
	}
	var url = '{SITE_URL}ajax/admin.php?m=saveCPitem';
	
	var data = $('#savedata').serialize();
		
	var callback = function(data)
	{
		if(data.sign == -2)
		{
			window.location = data.url;
		}
		else
		{
			if(data.sign == 1)
			{
				//添加成功,返回列表页
				layer.alert(data.msg,function(){
					window.location = $('#gotoList').attr('href');
				});
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('操作失败');
				}
			}
		}
	};
	makeAjax('post',url,data,callback);
}

function setInput()
{
	alert();
}

</script>
<body>
<div class="wrapper">
	<div class="crumbs"><a href="javascript:;">产品管理</a> &gt;<a href="{SITE_URL}admin.php?a=chanpinM">产品列表</a> &gt; <a id="gotoList" href="{SITE_URL}admin.php?a=chanpinM&m=itemlist&pid={$info[id]}">项目列表</a> &gt;<span>{$pagetitle}</span> </div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form id="savedata">
		<input type="hidden" name="id" value="{$item[id]}" />
		<input type="hidden" name="pid" value="{$info[id]}" />
		<h2 class="form_tit">产品基本信息</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">产品名称：</label>
				<label style="display: inline-block;line-height: 30px;height: 30px;width: 150px;text-align: right;">{$info[name]}</label>
			</p>
		</div>
		
		<h2 class="form_tit">投资项目信息</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">序号(排序)：</label>
				<input type="text" id="sort" name="sort" value="{$item[sort]}" class="text w200" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">名称：</label>
				<input type="text" id="name" name="name" value="{$item[name]}" class="text w200" />
			</p>
		</div>
		<div class="form_item clearfix">	
			<p class="clearfix">
				<label class="name">上传图片：</label>
				<a id="btn" href="javascript:;" class="btnyellow mr15">上传图片</a>
				<img id="img_tupian" src="{UPLOAD_IMG_URL}{$item[tupian]}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="tupian" name="tupian" value="{$item[tupian]}" />
			</p>
		</div>
		<div class="form_item clearfix">
			<p class="clearfix">
				<label class="name">链接地址：</label>
				<input type="text" id="link" name="link" value="{$item[link]}" class="text w200" />
			</p>
		</div>
		<div class="form_item clearfix">
			<p class="clearfix">
				<label class="name">投资期限：</label>
				<input type="text" id="qixian" name="qixian" value="{$item[qixian]}" class="text w200" />
			</p>
		</div>
		<div class="form_item clearfix">
			<p class="clearfix">
				<label class="name">返利类型：</label>
				{if empty($item) || $item['type']=='1'}
					<input style="vertical-align: middle;" checked class="checkbox" type="radio" name="type" value="1" />
					<label for="resort_index">返利比例</label>
					<input type="text" id="bili" name="bili" value="{$item['fanli']}" class="text w130" />
				{else}
					<input style="vertical-align: middle;" class="checkbox" type="radio" name="type" value="1" />
					<label for="resort_index">返利比例</label>
					<input type="text" id="bili" name="bili" value="" class="text w130" />
				{/if}
				
				
			</p>
			<p class="clearfix" style="padding-top:5px;">
				<label class="name"></label>
				{if $item['type']=='2'}
					<input style="vertical-align: middle;" checked class="checkbox" type="radio" name="type" value="2" />
					<label for="resort_index">固定金额</label>
					<input type="text" id="jine" name="jine" value="{$item['fanli']}" class="text w130" />
				{else}
					<input style="vertical-align: middle;" class="checkbox" type="radio" name="type" value="2" />
					<label for="resort_index">固定金额</label>
					<input type="text" id="jine" name="jine" value="" class="text w130" />
				{/if}
			</p>
		</div>

        <div class="form_item clearfix" style="padding-top: 20px;>
			<p class="clearfix">
				<label class="name"></label>
			    <input type="button" class="btnblue" value="提交" onclick="saveInfo();" />
			</p>
		</div>
    </form>
    </div>
</div>
<script>
    var uploader = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn', // 上传按钮
        url: "{SITE_URL}ajax/uploadImgs.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '2mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{UPLOAD_IMG_URL}';
	                $("#img_tupian").attr('src',picurl+data.name);
	                $("#tupian").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader.init();
</script>
</body>
</html>